import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入 view 组件
import {
  Announcement,
  Conf,
  Contest,
  ContestList,
  Home,
  JudgeServer,
  Login,
  Problem,
  ProblemList,
  User,
  PruneTestCase,
  Dashboard,
  ProblemImportOrExport,
  Banner,
  Course,
  Chapter,
  Section,
  Teacher,
  Coupon,
  Video,
  Order,
  ChapterOrder
} from './views'
Vue.use(VueRouter)

export default new VueRouter({
  mode: 'history',
  base: '/admin/',
  scrollBehavior: () => ({y: 0}),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/',
      component: Home,
      children: [
        {
          name: 'dashboard',
          path: '',
          component: Dashboard
        },
        {
          name: 'announcement',
          path: '/announcement',
          component: Announcement
        },
        {
          name: 'banner',
          path: '/banner',
          component: Banner
        },
        {
          name: 'course',
          path: '/course',
          component: Course
        },
        {
          name: 'coupon',
          path: '/coupon',
          component: Coupon
        },
        {
          name: 'video',
          path: '/video',
          component: Video
        },
        {
          name: 'order',
          path: '/order',
          component: Order
        },
        {
          name: 'chapterorder',
          path: '/chapterorder',
          component: ChapterOrder
        },
        {
          name: 'chapter',
          path: '/chapter',
          component: Chapter
        },
        {
          name: 'section',
          path: '/section',
          component: Section
        },
        {
          path: '/teacher',
          name: 'teacher',
          component: Teacher
        },
        {
          path: '/user',
          name: 'user',
          component: User
        },
        {
          path: '/conf',
          name: 'conf',
          component: Conf
        },
        {
          path: '/judge-server',
          name: 'judge-server',
          component: JudgeServer
        },
        {
          path: '/prune-test-case',
          name: 'prune-test-case',
          component: PruneTestCase
        },
        {
          path: '/problems',
          name: 'problem-list',
          component: ProblemList
        },
        {
          path: '/problem/create',
          name: 'create-problem',
          component: Problem
        },
        {
          path: '/problem/edit/:problemId',
          name: 'edit-problem',
          component: Problem
        },
        {
          path: '/problem/batch_ops',
          name: 'problem_batch_ops',
          component: ProblemImportOrExport
        },
        {
          path: '/contest/create',
          name: 'create-contest',
          component: Contest
        },
        {
          path: '/contest',
          name: 'contest-list',
          component: ContestList
        },
        {
          path: '/contest/:contestId/edit',
          name: 'edit-contest',
          component: Contest
        },
        {
          path: '/contest/:contestId/announcement',
          name: 'contest-announcement',
          component: Announcement
        },
        {
          path: '/contest/:contestId/problems',
          name: 'contest-problem-list',
          component: ProblemList
        },
        {
          path: '/contest/:contestId/problem/create',
          name: 'create-contest-problem',
          component: Problem
        },
        {
          path: '/contest/:contestId/problem/:problemId/edit',
          name: 'edit-contest-problem',
          component: Problem
        }
      ]
    },
    {
      path: '*', redirect: '/login'
    }
  ]
})
